Skip to content

Conversation

@digitalpardoe
Copy link
Owner

Test the use of Google Jules to rewrite the application from Ruby to Go and introduce tests.

google-labs-jules bot and others added 4 commits May 20, 2025 16:28
This commit rewrites the GitHub backup application from Ruby to Golang.
The core functionality of backing up repositories, including handling
Git LFS, remains the same.

Key changes include:
- Replaced `ghbackup.rb` with `main.go`.
- Updated `Dockerfile` to use a Go build environment, compile the Go
  application, and include necessary tools (git, git-lfs).
- The `entrypoint.sh` script remains largely unchanged, now executing
  the compiled Go binary.
- Introduced an `App` struct in `main.go` to manage dependencies like the
  GitHub client, command runner, and filesystem operations, improving
  testability.
- Added a comprehensive suite of unit tests in `main_test.go` using
  mocking for external dependencies (GitHub API, git commands, filesystem).
  This covers various scenarios including initial clone, repository updates,
  and error handling.
- Removed Ruby-specific files (`.ruby-version`, `ghbackup.rb`).
- Updated `README.md` to reflect the language change.
This commit addresses issues in `main_test.go` that caused tests to fail:

1.  The unused variable `authenticatedCloneURLRepo2` in the
    `TestAppRun_CloneErrorSkipsRepo` test was commented out to resolve
    a build error.
2.  The mock function `mockCmd.RunAndOutputFunc` within
    `TestAppRun_CloneErrorSkipsRepo` was updated. It was previously
    using an incorrect argument index (`args[3]`) to identify the
    repository URL for simulating a clone failure. This has been
    corrected to use the proper index (`args[4]`), allowing the test
    to accurately simulate the intended scenario and pass.

All tests now pass after these changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants